{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import torch\n",
    "import torchvision\n",
    "import torch.nn as nn\n",
    "import model\n",
    "import torchvision.transforms as transforms\n",
    "from dataset import SBDDataset\n",
    "from torch.utils.data import DataLoader\n",
    "import torch.optim as optim\n",
    "import train_utils\n",
    "from PIL import Image\n",
    "import numpy as np \n",
    "import os "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<function torchvision.models.segmentation.segmentation.fcn_resnet50(pretrained=False, progress=True, num_classes=21, aux_loss=None, **kwargs)>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "torch.backends.cudnn.benchmark = True\n",
    "fcn = torchvision.models.segmentation.fcn_resnet50\n",
    "fcn"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[0 1 2 3 4]\n",
      " [5 6 7 8 9]]\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "c  = np.arange(10).reshape(2,5)\n",
    "print(c.squeeze())\n",
    "\n",
    "a = \"1\"\n",
    "int(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[10, 11, 12],\n",
       "       [ 4,  5,  6]])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a = np.array([[1,2,3], [4,5,6]])\n",
    "a[0] = (10,11,12)\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'0000047.jpg'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tmp = os.listdir(\"./archive/images/\")\n",
    "total_n = 0\n",
    "for i in range(len(tmp)):\n",
    "    img = Image.open(\"./archive/images/\" + tmp[i])\n",
    "    image = np.array(Image.open(\"./archive/images/\" + tmp[i]))\n",
    "    if len(image) == 240 and len(image[0]) == 320:\n",
    "        total_n += 1\n",
    "        img.save(\"./archive/images_normliazed/\" + tmp[i])\n",
    "total_n\n",
    "tmp[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "7"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tmp = os.listdir(\"./archive/images/\")\n",
    "total_n = 0\n",
    "maxx = 0\n",
    "for i in range(len(tmp)):\n",
    "    key = tmp[i].split(\".\")[0]\n",
    "    with open(\"./archive/labels_raw/\" + key + \".regions.txt\") as f:\n",
    "        list_of_label = f.readlines()\n",
    "        for i in range(len(list_of_label)):\n",
    "            list_of_label[i] = list_of_label[i].strip().split()\n",
    "        for i in range(len(list_of_label)):\n",
    "            for j in range(len(list_of_label[0])):\n",
    "                list_of_label[i][j] = int(list_of_label[i][j])\n",
    "                maxx = max(maxx, list_of_label[i][j])\n",
    "maxx"
   ]
  }
 ],
 "metadata": {
  "interpreter": {
   "hash": "494899efd6527d56ea7f55c588d0081523a17dc3a9ff1107f3394ad815ff2527"
  },
  "kernelspec": {
   "display_name": "Python 3.7.7 64-bit",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
